package bb.lanxing.util;

import android.app.Application;

import com.igexin.sdk.IUserLoggerInterface;
import com.igexin.sdk.PushManager;
import com.zx.sdk.api.ZXManager;

import bb.lanxing.App;
import bb.lanxing.BuildConfig;

public class MessageUtil {
    private static final String TAG = "MessageUtil";
    public static void triggerHuanXin(boolean z) {
    }

    private static void startAuth() {

        //TODO llkll，确认新版本个推是否需要鉴权。目前不鉴权也可以收到推送
//        AuthInteractor interactor = new AuthInteractor();
//        interactor.checkTime(this);
//        interactor.fetchAuthToken(this);
    }

    public static void triggerGetui(boolean enable) {
        Application app = App.getContext();
        if (enable) {
            startAuth();

            String version = ZXManager.getVersion();
            android.util.Log.d(TAG, "initializing sdk...");
            PushManager.getInstance().preInit(app);
            PushManager.getInstance().initialize(app);
            if (BuildConfig.DEBUG) {
                //切勿在 release 版本上开启调试日志
                PushManager.getInstance().setDebugLogger(app, new IUserLoggerInterface() {

                    @Override
                    public void log(String s) {
                        Log.logi(TAG, s);
                    }
                });
            }
            PushManager.getInstance().turnOnPush(App.getContext());
            return;
        }
        PushManager.getInstance().turnOffPush(App.getContext());
    }
}
